import Vue from "vue";

import App from "./App.vue";

import Home from "./Home.vue";
import Shop from "./Shop.vue";
import User from "./User.vue";

import VueRouter from "vue-router";

Vue.use(VueRouter); //插件

const router = new VueRouter({
  routes: [
    {
      path: "/home/list",
      component: Home,
    },
    {
      path: "/shop/1",
      component: Shop,
    },
    {
      path: "/user/id/1",
      component: User,
    },
  ],
});

const plugin = {
  install(Vue) {
    Vue.mixin({
      computed: {
        $info() {
          return this.$root.$options.info;
        },
      },
    });
  },
};

Vue.use(plugin);

new Vue({
  render: (h) => h(App),
  router, //路由注入
  info: { age: 20 },
}).$mount("#app");
